Change configuration handling wrt to the vcpus entry, so that we only see a
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 7 Dec 2005 11:50:55 +0000 (11:50 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 7 Dec 2005 11:50:55 +0000 (11:50 +0000)
vcpus entry in the image section when using VMX, only add VMX options at all
if the builder is vmx, and issue a warning when overriding the global vcpus
setting with the one from the image.

This removes the duplicated vcpus entries in the domain's sxpr.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xm/create.py

index 13eae448b7cd1b0f56585d3acc01988f3b5a1362..ce054bb3a03e8fa9ccd325b0af7260cdcdba8fe8 100644 (file)
@@ -285,16 +285,18 @@ def parseConfig(config):
     for e in ROUNDTRIPPING_CONFIG_ENTRIES:
         result[e[0]] = get_cfg(e[0], e[1])
 
-    result['cpu']       = get_cfg('cpu',       int)
-    result['cpus']      = get_cfg('cpus',      str)
-    result['image']     = get_cfg('image')
+    result['cpu']   = get_cfg('cpu',  int)
+    result['cpus']  = get_cfg('cpus', str)
+    result['image'] = get_cfg('image')
 
     try:
         if result['image']:
-            result['vcpus'] = int(sxp.child_value(result['image'],
-                                                  'vcpus', 1))
-        else:
-            result['vcpus'] = 1
+            v = sxp.child_value(result['image'], 'vcpus')
+            if v is not None and int(v) != result['vcpus']:
+                log.warn(('Image VCPUs setting overrides vcpus=%d elsewhere.'
+                          '  Using %s VCPUs for VM %s.') %
+                         (result['vcpus'], v, result['uuid']))
+                result['vcpus'] = int(v)
     except TypeError, exn:
         raise VmError(
             'Invalid configuration setting: vcpus = %s: %s' %
index 8b8e55517f3b58ac9b586fd91a78beffd4b92b69..622bea9b18a5796efba83d2b895c7c7674065ceb 100644 (file)
@@ -424,8 +424,10 @@ def configure_image(vals):
         config_image.append(['root', cmdline_root])
     if vals.extra:
         config_image.append(['args', vals.extra])
-    if vals.vcpus:
-        config_image.append(['vcpus', vals.vcpus])
+
+    if vals.builder == 'vmx':
+        configure_vmx(config_image, vals)
+        
     return config_image
     
 def configure_disks(config_devs, vals):
@@ -573,7 +575,7 @@ def make_config(vals):
                 config.append([n, v])
 
     map(add_conf, ['name', 'memory', 'ssidref', 'maxmem', 'restart',
-                   'on_poweroff', 'on_reboot', 'on_crash'])
+                   'on_poweroff', 'on_reboot', 'on_crash', 'vcpus'])
     
     if vals.cpu is not None:
         config.append(['cpu', vals.cpu])
@@ -593,7 +595,6 @@ def make_config(vals):
         config_image = run_bootloader(vals)
     else:
         config_image = configure_image(vals)
-    configure_vmx(config_image, vals)
     config.append(['image', config_image])
 
     config_devs = []